package com.vornitologist;

import com.vaadin.addon.touchkit.ui.TouchKitApplication;
import com.vaadin.addon.touchkit.ui.TouchKitWindow;
import com.vornitologist.ui.LoginView;


public class VornitologistApplication extends TouchKitApplication {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
     * Make application reload itself when the session has expired. Our demo app
     * gains nothing for showing session expired message.
     * 
     * @see TouchKitApplication#getSystemMessages()
     */
    public static SystemMessages getSystemMessages() {
        return customizedSystemMessages;
    }

    static CustomizedSystemMessages customizedSystemMessages = new CustomizedSystemMessages();
    static {
        customizedSystemMessages.setSessionExpiredNotificationEnabled(false);
    }

    private TouchKitWindow mainWindow;

    /*
     * Default the location to Vaadin HQ
     */
    private double currentLatitude = 60.452541;
    private double currentLongitude = 22.30083;

    @Override
    public void init() {
       
        configureMainWindow();
        setTheme("vornitologist");
        
    }

   
    @Override
    public void onBrowserDetailsReady() {
        
    	mainWindow.setContent(new LoginView(mainWindow));
    }

    private void configureMainWindow() {
        mainWindow = new VornitologistWindow();
        setMainWindow(mainWindow);
    }

   
    public double getCurrentLatitude() {
        return currentLatitude;
    }

   
    public double getCurrentLongitude() {
        return currentLongitude;
    }

    /**
     * @see #getCurrentLatitude()
     */
    public void setCurrentLatitude(double currentLatitude) {
        this.currentLatitude = currentLatitude;
    }

    /**
     * @see #getCurrentLatitude()
     */
    public void setCurrentLongitude(double currentLongitude) {
        this.currentLongitude = currentLongitude;
    }

    /**
     * TouchKitApplication already provides access to currently active
     * application instance with "thread local pattern". The approach is handy
     * as we commonly store e.g. settings in the application instance (location
     * information in this example). Otherwise we'd need to pass references to
     * UI components in constructors or provided another mechanism to access
     * active class (e.g. CDI). This is a better typed version of the one that
     * TouchKitApplication provides for convenience.
     * 
     * @return the currently active Vornitologist application.
     */
    public static VornitologistApplication getApp() {
        return (VornitologistApplication) get();
    }

}
